<template>
  <div class="body-box">
    <window-title title="团报列表"></window-title>
    <div class="table-box">
      <el-table size="mini" :header-cell-style="{background:'#f8f8f8',color:'#333',borderRight:0}" border :data="list">
        <el-table-column type="index" width="50px" label="序号"></el-table-column>
        <el-table-column label="名称">
          <template slot-scope="item">
            <el-link size="mini" type="primary" style="font-size:12px;">{{item.row.name}}</el-link>
          </template>
        </el-table-column>
        <el-table-column label="开启密码" width="80">
          <template slot-scope="item">
            <el-tag size="mini" type="success" v-if="item.row.open_pwd">开启</el-tag>
            <el-tag size="mini" type="danger" v-else>未开启</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="团报基数" width="80">
          <template slot-scope="item">
            <span v-if="item.row.open_base">{{item.row.base_num}}</span>
            <el-tag size="mini" type="danger" v-else>未开启</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="团报人数" prop="real_sign" width="80">
          <template slot-scope="item">{{item.row.real_sign}} / {{item.row.total_people}}</template>
        </el-table-column>
        <!-- <el-table-column label="团报人数" prop="total_people" width="60"></el-table-column> -->
        <el-table-column label="状态" width="60">
          <template slot-scope="item">
            <el-tag size="mini" type="success" v-if="item.row.state == 1">开启</el-tag>
            <el-tag size="mini" type="danger" v-else>禁用</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="有效期" width="180">
          <template slot-scope="item">{{item.row.start_time}} - {{item.row.end_time}}</template>
        </el-table-column>
        <!-- <el-table-column label="创建时间" width="150" prop="create_time"></el-table-column> -->
        <el-table-column label="操作" width="150">
          <template slot-scope="scope">
            <el-button size="mini" @click="showTeam(scope.$index)" icon="el-icon-view">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog title="团报信息" :append-to-body="true" :visible.sync="dialogTeam" width="50%">
      <el-form
        size="mini"
        label-position="right"
        label-width="80px"
        disabled
        :model="list[teamIndex]"
      >
        <el-form-item label="团报名称">
          <el-input size="mini" v-model="list[teamIndex].name"></el-input>
        </el-form-item>
        <el-form-item label="开启密码">
          <el-switch size="mini" v-model="list[teamIndex].open_pwd"></el-switch>
        </el-form-item>
        <el-form-item label="限定跑团">
          <el-switch v-model="list[teamIndex].limitRun"></el-switch>
          <el-table v-if="list[teamIndex].limitRun" style="margin-top:10px" size="mini" border :data="list[teamIndex].run">
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="logo" label="Logo">
              <template slot-scope="scope">
                <el-image style="width:50px" :src="scope.row.logo"></el-image>
              </template>
            </el-table-column>
            <el-table-column prop="runName" label="跑团名称"></el-table-column>
            <el-table-column prop="colonel" label="团长"></el-table-column>
            <el-table-column prop="city" label="城市"></el-table-column>
          </el-table>
        </el-form-item>
        <el-form-item label="团报基数">
          <el-input size="mini" v-model="list[teamIndex].base_num"></el-input>
        </el-form-item>
        <el-form-item label="报名设置">
          <el-table style="margin-top:10px" size="mini" border :data="list[teamIndex].group">
            <el-table-column type="index" label="序号"></el-table-column>
            <el-table-column prop="groupName" label="组别"></el-table-column>
            <el-table-column prop="userNum" label="使用次数"></el-table-column>
            <el-table-column prop="price" label="价格"></el-table-column>
          </el-table>
        </el-form-item>
           <el-form-item label="团报总数">
          <el-input size="mini" v-model="list[teamIndex].total_people">
            <template slot="append">人</template>
          </el-input>
        </el-form-item>
        <el-form-item label="有效期">
           <el-date-picker
            type="daterange"
            range-separator="至"
            :start-placeholder="list[teamIndex].start"
            :end-placeholder="list[teamIndex].end">
          </el-date-picker>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import windowTitle from "../../../components/unit/title.vue";

export default {
  components: { windowTitle },
  props: { active_id: {} },
  data() {
    return {
      dialogTeam: false,
      list: [
        {
          name: "报名",
          open_pwd: true,
          real_sign: "2",
          limitRun: false,
          start:'2020-01-09',
          end:'2020-021-09',
          run: [
            {
              logo: require("../../../assets/img/brand05.png"),
              runName: "跑团",
              colonel: "是否",
              city: "北京"
            }
          ],
          group: [
            {
              groupName: "三人行",
              userNum: "20",
              price: "20.00"
            }
          ],
          base_num: "10",
          total_people: "20",
          state: 1,
          id: 1
        }
      ],
      teamIndex: 0,
      load: true
    };
  },
  mounted() {},
  methods: {
    showTeam(index) {
      this.teamIndex = index;
      console.log(index);
      this.dialogTeam = true;
    },

    //添加团报
    addTeamSign() {
      this.$layer.iframe({
        content: {
          // content: addTeam, //传递的组件对象
          parent: this, //当前的vue对象
          data: {
            active_id: this.active_id,
            id: 0
          } //props
        },
        area: ["800px", "600px"],
        title: "添加团报"
      });
    }
  }
};
</script>

<style>
.table-box {
  margin-top: 10px;
}
.group-sign-table {
  width: 100%;
  border-collapse: collapse;
}
.group-sign-table th,
.group-sign-table td {
  text-align: left;
  padding-left: 10px;
  height: 32px;
  line-height: 32px;
  border: 1px solid #e1e1e1;
}
</style>